<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			<school></school>
			<hr>
			<student></student>
			<hr >
			<hello></hello>
		</div>
		<script type="text/javascript">
			const school = Vue.extend({
				template: `
					<div>
						<h2>学校名称:{{schoolName}}</h2>
						<h2>学校地址:{{address}}</h2>
						<button @click="showAddress">点我显示学校地址</button>
					</div>
			`,
				data() {
					return {
						schoolName: '老八',
						address: '厕所',

					}
				},
				methods: {
					showAddress() {
						alert(this.address)
					}
				}
			})

			const student = Vue.extend({
				template: `
					<div>
						<h2>学生姓名:{{studentName}}</h2>
						<h2>学校年龄:{{age}}</h2>
					</div>
				`,
				data() {
					return {
						studentName: '邹宜臻',
						age: 16
					}
				}
			})

			const hello = Vue.extend({
				template: `
					<div>
						<h2>你好,{{name}}</h2>
					</div>
				`,
				data() {
					return {
						name: '邹宜臻'
					}
				}
			})
			Vue.component('hello', hello)

			const vm = new Vue({
				el: '#root',
				components: {
					school,
					student
				}
			})
		</script>
	</body>
</html>
